#!/bin/sh
"""": # -*-python-*-
bup_exec="$(dirname "$0")/bup-exec" || exit $?
exec "$bup_exec" "$0" ${1+"$@"}
"""


from os.path import getsize, isdir
from sys import stderr
import os

from bup.compat import get_argvb


def listdir_failure(ex):
    raise ex

def usage():
    print('Usage: data-size PATH ...', file=sys.stderr)

total = 0
for path in get_argvb()[1:]:
    if isdir(path):
        for root, dirs, files in os.walk(path, onerror=listdir_failure):
            total += sum(getsize(os.path.join(root, name)) for name in files)
    else:
        total += getsize(path)

print(total)
